/*
 * Copyright (c) 2008 Ricardo Rocha, rocha.porto@gmail.com
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package org.gliding.kumulus.client;

import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.SimplePanel;
import com.google.gwt.user.client.ui.Widget;

/**
 * Class defining a wrapper for all planning menu components.
 * 
 * It provides a single and homogeneous wrapper for all the components
 * of the planning menu, useful for things like setting a common rounded
 * corners layout.
 * 
 * @author Ricardo Rocha <rocha.porto@gmail.com>
 * @version $Rev:: $
 * 
 * @see org.gliding.kumulus.client.Planning
 */
public class PlanningMenuWidget extends Composite {

	/**
	 * A panel hosting the actual widget.
	 */
    private SimplePanel menuPanel;
    
	/**
	 * Class constructor.
	 */
	public PlanningMenuWidget(Widget w, boolean rounded, boolean selected) {
		// If the widget should be rounded
        if (rounded) {
            menuPanel = new RoundedPanel(w, RoundedPanel.LEFT);
            // Set a different CSS layout for selected or not selected widgets
            if (selected) {
                ((RoundedPanel)menuPanel).setCornerStyleName("kumulus-WidgetCornerSelected");
            } else {
                ((RoundedPanel)menuPanel).setCornerStyleName("kumulus-WidgetCorner");
            }
        } 
        // Or if the widget should not be rounded
        else {
            menuPanel = new SimplePanel();
            menuPanel.add(w);
        }
        
        // Initialize the widgets and its CSS layout
        initWidget(menuPanel);
        setStyleName("kumulus-PlanningMenuWidget");
	}

}
